package cn.rengy.auth;

import java.security.Principal;

/**
 * 其实可以直接使用RequestContextHolder,在servlet环境中
 */
public class UserContextHolder {
    private static final ThreadLocal<Principal> PRINCIPAL_LOCAL = new ThreadLocal<>();

    public static void set(Principal principal) {
        PRINCIPAL_LOCAL.set(principal);
    }

    public static Principal get() {
        return PRINCIPAL_LOCAL.get();
    }

    public static void clear() {
        PRINCIPAL_LOCAL.remove();
    }
}
